<?php
if(!defined('IN_BSTO')){ die('[ERROR] You cannot load this page directly !!!'); }

Class IndexController Extends BaseController {

    public function index() {
        //$db = new DB();
        $numOfBook = $this->registry->db->get('configManager')->getByKey('FeaturePageSize')->get('value');
        $specialBooks = $this->registry->db->get('bookManager')->getSpecialBooks(0, $numOfBook);
        $numOfBook = $this->registry->db->get('configManager')->getByKey('NewPageSize')->get('value');
        $newBooks = $this->registry->db->get('bookManager')->getNewLimit(0, $numOfBook);                        
        
        $leftContent = $this->registry->template->getFeatureBooksContent($specialBooks);        
        $leftContent .= $this->registry->template->getNewBooksContent($newBooks);	        

        $this->registry->template->setMenuKey('home');
        $headContent = '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta property="og:title" content="Book Store" />
<meta property="og:type" content="book" />
<meta property="og:url" content="{statisticURL}" />
<meta property="og:image" content="{statisticURL}views/images/aboutus.jpg" />
<meta property="og:site_name" content="Book Store" />
<meta property="og:description" content="SAD !^^" />
<meta property="fb:admins" content="1416293132" />';
        $tags = array('bstoHead'=>$headContent);
    	$user = $this->registry->db->get('userManager')->getCurrentUser();
        if($user != null){
        	$tags['login'] = '<li id="login"><span> Hello, '. $user->get('username').'</span><a href="{bstoRootPath}logout">Logout</a></li>';	
        }else{
        	$tags['login'] = '<li id="login"><a href="{bstoRootPath}login">Login</a></li>';
        }
        $output = $this->registry->template->getPageContent('index', 'Book Store', $leftContent, $tags);
        
        echo $output;      
    }

}

?>
